﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Agile.Common;

namespace Agile.Genie.Descriptors.Extensions
{
    /// <summary>
    /// Description of GenieExtensions...
    /// </summary>
    public static class GenieExtensions
    {
        /// <summary>
        /// Converts the string to camel casing. ie. changes MyVariableName to myVariableName
        /// </summary>
        /// <param name="code">string to convert to camel case.</param>
        public static string ToCamelCase(this String code)
        {
            if (code.Equals(string.Empty))
                return String.Empty;
            string firstCharacter = code.Substring(0, 1);
            var builder = new StringBuilder(code);
            return builder.Replace(firstCharacter, firstCharacter.ToLower(), 0, 1).ToString();
        }
        /// <summary>
        /// Returns the given string with 'Pascal casing'
        /// </summary>
        /// <example>'someString' returns 'SomeString'.
        /// NOTE: at the moment 'somestring' should return 'SomeString' but it currently will only return 
        /// 'Somestring' (this should change in the future).</example>
        /// <param name="convertToPascalCase">the string to be converted to pascal casing.</param>
        /// <returns></returns>
        public static string ToPascalCase(this string convertToPascalCase)
        {
            if (convertToPascalCase.Equals(string.Empty))
                return String.Empty;
            string firstCharacter = convertToPascalCase.Substring(0, 1);
            var builder = new StringBuilder(convertToPascalCase);
            return builder.Replace(firstCharacter, firstCharacter.ToUpper(), 0, 1).ToString();
        }
    }
}
